<!DOCTYPE html>

<html lang="en">

<head>
  <meta charset="UTF-8" />

  <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <title>添加点击事件</title>
</head>

<body>
  js click 与 onclick 事件绑定,触发与解绑
  https://www.cnblogs.com/ooo0/p/7742214.html

  <button id="btn">点击一下吧</button>
  <script>
    var btn = document.getElementById("btn");

    btn.onclick = function () {
      alert("这就是点击事件~");
    };
  </script>
</body>

</html>